<template>
	<view class="technician-income-index" :style="{background:pageColor}" v-if="isLoad">
		<view @tap.stop="toApplyCash('cap_cash')" class="mine-menu-list c-base" :style="{background:primaryColor}">
			<view class="space-lg"></view>
			<view class="space-lg"></view>
			<view class="flex-center f-caption mt-sm">可提现金额(元)</view>
			<view class="money-info flex-center flex-y-baseline mt-sm mb-sm">¥<view class="money">
					{{detail.partner_money}}
				</view>
			</view>
			<view class="flex-center pt-md pb-md pl-lg pr-lg f-caption c-base-rgba">
				{{['每月提现不限次数','每月1号提现上月1号至15号完成的订单，每月16号提现上月16号至月末完成的订单，每月提现2次','每周一可提现上上周及以前的业绩提成'][0]}}
			</view>
			<view class="cash-out-btn flex-center fill-base f-paragraph radius" :style="{color: primaryColor}">提现
			</view>
			<view class="space-lg"></view>
			<view class="space-lg"></view>
		</view>
		<view class="money-count fill-base flex-center pt-md pb-md">
			<view class="item-child flex-center flex-column">
				<view class="flex-y-baseline f-md-title mb-sm">{{detail.total_partner_money}}</view>
				<view class="f-caption c-caption">总收入(元)</view>
			</view>
			<!-- <view class="item-child flex-center flex-column b-1px-l"
				v-if="detail.coach_service_wallet_cash_t_type*1>0 && options.type*1 == 2">
				<view class="flex-y-baseline f-md-title mb-sm">{{detail.freeze_cash}}</view>
				<view class="f-caption c-caption">冻结金额(元)</view>
			</view> -->
			<view class="item-child flex-center flex-column b-1px-l">
				<view class="flex-y-baseline f-md-title mb-sm">{{detail.partner_wait_money}}</view>
				<view class="f-caption c-caption">未入账(元)</view>
			</view>
		</view>

		<view class="fill-base mt-md pl-lg pr-lg">
			<view @tap.stop="$util.goUrl({url:`/userA/pages/distribution/record?type=9`})"
				class="flex-between pt-lg pb-lg">
				<view class="f-title c-title">提现记录</view>
				<view class="flex-y-center f-paragraph c-title">
					<view class="c-warning" v-if="detail.extract_ing_price*1>0">提现中 {{detail.extract_ing_price}}元</view>
					<i class="iconfont icon-right ml-sm"></i>
				</view>
			</view>
		</view>
		<view class="space-footer"></view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from "vuex"
	export default {
		components: {},
		data() {
			return {
				isLoad: false,
				options: {},
				detail: {},
			}
		},
		computed: mapState({
			configInfo: state => state.config.configInfo,
		}),
		onLoad(options) {
			let {
				type = 2
			} = options
			type = type * 1
			options.type = type
			this.options = options
			this.initIndex()
			// uni.setNavigationBarTitle({
			// 	title: type == 2 ? '服务费提现' : '车费提现'
			// })
		},
		onPullDownRefresh() {
			// #ifndef APP-PLUS
			uni.showNavigationBarLoading()
			// #endif
			this.initRefresh();
			uni.stopPullDownRefresh()
		},
		methods: {
			...mapMutations([]),
			async initIndex(refresh = false) {
				this.$util.showLoading()
				let {
					type
				} = this.options
				this.detail = await this.$api.partner.partnerMoneyInfo()
				this.$util.setNavigationBarColor({
					bg: this.primaryColor
				})
				this.isLoad = true
				this.$util.hideAll()
				// #ifdef H5
				if (!refresh) {
					this.$jweixin.hideOptionMenu()
				}
				// #endif
			},
			initRefresh() {
				this.initIndex(true)
			},
			toApplyCash(key) {
				let cash = this.detail[key]
				if (cash * 1 == 0) {
					this.$util.showToast({
						title: `暂无可提现金额哦`
					})
					return
				}
				this.$util.goUrl({
					url: `/user/pages/cash-out?type=partner`
				})
			}
		}
	}
</script>


<style lang="scss"> 

	.technician-income-index {

		.mine-menu-list {
			.money-info {
				font-size: 50rpx;

				.money {
					font-size: 70rpx;
				}
			}

			.cash-out-btn {
				width: 169rpx;
				height: 56rpx;
				margin: 0 auto;
			}

			.menu-title {
				height: 90rpx;

				.iconfont {
					font-size: 24rpx;
				}
			}

			.item-child {
				width: 25%;
				margin: 10rpx 0;

				.iconfont {
					font-size: 46rpx;
				}
			}


		}


		.money-count {
			.item-child {
				width: 50%;
			}
		}

		.icon-right {
			font-size: 28rpx;
		}

	}
</style>